package com.heima.media.controller;

import com.heima.media.dto.SensitiveDto;
import com.heima.common.dto.ResponseResult;
import com.heima.media.entity.WmSensitive;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.heima.media.service.IWmSensitiveService;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 敏感词信息表 前端控制器
 * </p>
 *
 * @author itheima
 * @since 2022-07-03
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词信息表接口")
@CrossOrigin
public class WmSensitiveController{
    @Autowired
    private IWmSensitiveService wmSensitiveService;

    /**
     * 敏感词分页查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult querByPage(@RequestBody SensitiveDto dto){
        return wmSensitiveService.querByPage(dto);
    }

    /**
     * 新增敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping
    public ResponseResult saveWmSensitive (@RequestBody WmSensitive wmSensitive){
        return wmSensitiveService.saveWmSensitive(wmSensitive);
    }

    /**
     * 编辑敏感词
     * @param wmSensitive
     * @return
     */
    @PutMapping
    public ResponseResult UpdateWmSensitive (@RequestBody WmSensitive wmSensitive){
        return wmSensitiveService.updateWmSensitive(wmSensitive);
    }
    /**
     * 删除敏感词
     * @param wmSensitive
     * @return
     */
    @DeleteMapping("{id}")
    public ResponseResult DeleteWmSensitive (@PathVariable Integer id){
        wmSensitiveService.removeById(id);
        return ResponseResult.okResult();
    }



}
